<template>
	<div>
		<div style="margin-left: 30%;margin-top: 60%">
			<div style="margin-bottom: 10%;">
				<van-tag type="primary" size="large" style="margin-top: 3%;margin-right: 3%;">午餐</van-tag>
				<van-tag type="primary" size="large" style="margin-top: 3%;margin-right: 3%;">{{ lunch_peo_num }}人</van-tag>
			</div>
			<div>
				<van-tag type="warning" size="large" style="margin-top: 3%;margin-right: 3%;">晚餐</van-tag>
				<van-tag type="warning" size="large" style="margin-top: 3%;margin-right: 3%;">{{ supper_peo_num }}人</van-tag>
			</div>
		</div>
		
	</div>
</template>

<script>
	import { BaseUrl } from '@/util/util.js';
	const PrefixUrl = BaseUrl();
	export default {
		data(){
			return{
				lunch_peo_num: '0',
				supper_peo_num: '0'
			}
		},
		created() {
			uni.request({
				method: 'POST',
				url: PrefixUrl + '/imdFoodPeoNum/getPeoNum',
				data: {
					time: this.format(new Date())
				},
				header: {
					'content-type': 'application/x-www-form-urlencoded',
					'token': uni.getStorageSync('token')
				},
				success: (res) => {
					for(let i = 0; i < res.data.obj.length; i++){
						if(res.data.obj[i].foodName === '午餐'){
							this.lunch_peo_num = res.data.obj[i].peoNum;
						}
						if(res.data.obj[i].foodName === '晚餐'){
							this.supper_peo_num = res.data.obj[i].peoNum;
						}
					}
				}
			});
		},
		methods:{
			//格式化时间
			format(dat) {
				//获取年月日，时间
				var year = dat.getFullYear();
				var mon = (dat.getMonth() + 1) < 10 ? "0" + (dat.getMonth() + 1) : dat.getMonth() + 1;
				var data = dat.getDate() < 10 ? "0" + (dat.getDate()) : dat.getDate();
				var hour = dat.getHours() < 10 ? "0" + (dat.getHours()) : dat.getHours();
				var min = dat.getMinutes() < 10 ? "0" + (dat.getMinutes()) : dat.getMinutes();
				var seon = dat.getSeconds() < 10 ? "0" + (dat.getSeconds()) : dat.getSeconds();
				var newDate = year + '-' + mon + '-' + data;
				return newDate;
			},
		}
	} 
</script>

<style>
</style>